<?php 

namespace Admin\Controller;
use Think\Controller;

/**
* 
*/
class GoodController extends Controller
{
	
	function show(){

		$n = new \Model\GoodsModel();
		
		//selected 查询

		/*
		查询id小于20
		$map['goods_id']  = array('lt' ,'20' );
		$info = $n->where($map)->select(); 

		//查询id大于20
		$map['goods_id'] = array('gt','20');
		$info = $n ->where($map) ->sleected();

		//like 模糊查询
		// [NOT] NETWEEN 在区间内
		// [NOT] IN    
			
		// 模糊搜索   
		$map['goods_name']  = array('like' ,'诺%' );
		$info = $n->where($map)->select();  
		
		//分页查询
		$info = $n->limit(5)->select();

		//限制查询字段
		$n->field('字段名','字段名') -> selected();
		
		//排序查询
		 order('goods_price desc')

		//分组查询  ,推荐使用原生的SQL语句来编辑
		group()


		//where he having 的区别

		having 条件字段必须是结果集中的字段
 		
 		where 条件字段必须是数据库中存在的字段 


		1. 只能使用where 的情况

		select goods_id,goods_name form sw_goods where goods_price >100

		select goods_id,goods_name form sw_goods having goods_price >100 错误的,结果集中不存在条件字段


		2.只能使用having 

		select goods_brand_id,count(*) as cnt form sw_goods having cnt > 3;
		select goods_brand_id, count(*) as cnt form sw_goods where cunt > 3;

		数据库操作与局可以使用连贯操作进行查询; 代码更整洁
		



		*/

		$map['goods_name']  = array('like' ,'诺%' );
		$info = $n->where($map)->select(); 

		

		// dump($n);

		// dump($info);

		$this -> assign('info',$info);

		$this->display();

	}

	function add(){
		$this->display();
	}


	function update(){
		$this->display();

	}


}